package com.zhida.courseservice.controller;

import com.zhida.common.entity.Result;
import com.zhida.common.utils.TokenProcessor;
import com.zhida.courseservice.entity.Course;
import com.zhida.courseservice.service.ICourseService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ling
 * @since 2024-07-17
 */
@RestController
@RequestMapping("/course")
public class CourseController {

    @Resource
    ICourseService courseService;

    @PostMapping("/createCourse")
    public Result<?> createCourse(@RequestBody Course course){
        return courseService.createCourse(course);
    }

    @GetMapping("/getCourseInfo/{course_id}")
    public Result<?> getCourseInfo(@PathVariable Integer course_id){
        return courseService.getCourseInfo(course_id);
    }

    @PostMapping("/updateCourseInfo")
    public Result<?> updateCourseInfo(@RequestBody Course course){
        return courseService.updateCourseInfo(course);
    }

    @GetMapping("/getCourses/{current}/{pageSize}")
    public Result<?> getCourses(@PathVariable Integer current,@PathVariable Integer pageSize){
        return courseService.getCourses(current,pageSize);
    }
}
